package nc.ui.cmp.applaybill.command;

import nc.ui.applaybill.enum1.FunCode;
import nc.ui.cmp.applaybill.ClientUI;
import nc.ui.cmp.applaybill.common.UIUtil;
import nc.ui.fi_print.entry.FiPrintEntry;
import nc.ui.fi_print.entry.FiPrintEntryFactory;
import nc.ui.pub.ButtonObject;
import nc.ui.trade.bocommand.IButtonCommand;
import nc.ui.trade.controller.IControllerBase;
import nc.ui.trade.manage.BillManageUI;
import nc.ui.trade.manage.ManageEventHandler;

public class PrintBoCommand extends ManageEventHandler implements IButtonCommand {
	
	private FunCode code;
	
	private ClientUI clientUI;

	public PrintBoCommand(BillManageUI billUI, IControllerBase control) {
		super(billUI, control);
		// TODO Auto-generated constructor stub
	}

	@SuppressWarnings("restriction")
	public void execute(ButtonObject bo) throws Exception {
		clientUI = (ClientUI)getBillUI();
		code = UIUtil.convertToFunCode(clientUI.getUiContext().getNodeNo());
		if(clientUI.isListPanelSelected()) {
			printList();
		}else {
			printCard();
		}
	}
	
	@SuppressWarnings("restriction")
	private void printList() throws Exception {
		FiPrintEntry entry = FiPrintEntryFactory.createBillListPanelPrintEntry(clientUI.getBillListPanel(), true);
		if(code == FunCode.ACCOUNT_APPLY || code == FunCode.ACCOUNT_MNG) {
			entry.printView(clientUI._getCorp().getPk_corp(), "20040801", "list");
		}else {
			entry.printView(clientUI._getCorp().getPk_corp(), "20040803", "list");
		}
	}
	
	@SuppressWarnings("restriction")
	private void printCard() throws Exception {
		FiPrintEntry entry = FiPrintEntryFactory.createBillCardPanelFiPrintEntry(clientUI.getBillCardPanel());
		if(code == FunCode.ACCOUNT_APPLY || code == FunCode.ACCOUNT_MNG) {
			entry.printView(clientUI._getCorp().getPk_corp(), "20040801", "card");
		}else {
			entry.printView(clientUI._getCorp().getPk_corp(), "20040803", "card");
		}
	}
	

}
